package com.itheima.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.Date;

@Mapper
public interface MemberMapper {

    /**
     * 根据日期统计会员数量
     * @param date
     * @return
     */
    Integer countMemberByDate(LocalDate date);

    /**
     * 查询今日新增会员数
     * @return
     */
    @Select("select count(*) from t_member where regTime = #{localDate}")
    Integer findTodayNewMember(LocalDate localDate);

    /**
     * 查询本周新增会员数
     * @return
     */
    @Select("select count(*) from t_member where regTime >= date (#{thisWeekMonday})")
    Integer findThisWeekNewMember(Date firstDayOfWeek);

    /**
     * 本月新增会员数
     * @param firstDay4ThisMonth
     * @return
     */
    @Select("select count(*) from t_member where regTime >= date (#{firstDay4ThisMonth})")
    Integer findThisMonthNewMember(Date firstDay4ThisMonth);
}
